<?php


namespace app\api\controller;


use app\admin\model\Record;
use app\common\controller\Api;
use think\Db;


class Wxlog extends Api{

    protected $userId;

    //手机端日志列表
    public function log()
    {
        $adminId = $this->userId;

        $params = $this->request->param();
        $page = $params['page'];
        $pageCount = $params['pageCount'];
        $record = new Record();
        $info = $record->getInfo(null,null,null,$adminId,null,"status asc, weigh desc,id desc",null,$page ,$pageCount );
        //总数

        $total = Record::where(['admin_id'=>$adminId])->count();
        $result['total'] = $total;
        $result['info'] = $info;
        $result['pageTotal'] = count($info);
        $this->success('请求成功!!!',$result);

    }


    //手机端未完成日志数量
    public function incompletelog(){
        $adminId = $this->userId;
        $record = new Record();
        $info = $record->getInfo(null,null,null,$adminId,"0",null,null,null ,null );
        //总数
        $total = Record::where(['admin_id'=>$adminId,'status'=> "0"])->count();
        $result['total'] = $total;
        $this->success('请求成功!!!',$result);


    }

    //完成项目
    public function completelog(){

        $params = $this->request->param();
        $id = $params['id'];
        $flag = Db::table('zc_record')->where('id', $id)->update(['status' => '1']);
        if($flag == 1){
            $this->success('成功!!!');
        }else{
            $this->error('请求失败!!!');
        }


    }






}